package net.pimpas.web.tests.bb;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import javax.faces.event.ActionEvent;

import net.pimpas.web.jsf.managedbean.ManagedBeanAnnotation;

@ManagedBeanAnnotation(beanName="crudCar", beanScope="session")
public class CrudCar {
	
	private Car car;
	private List<Car> cars;
	
	public CrudCar() {
		this.setCar(new Car());
		this.setCars(new ArrayList<Car>());
	}
	
	public String getRandomText() {
		return String.valueOf(new Random(System.currentTimeMillis()).nextLong());
	}

	public int getQnt( ) {
		return this.getCars().size();
	}
	
	
	public void addCar(ActionEvent evt) {
		this.getCars().add(this.getCar());
		this.setCar(new Car());
	}
	
	public void deleteCar(ActionEvent evt) {
		this.getCars().remove(this.getCar());
		this.setCar(new Car());
	}
	
	public void findCar(ActionEvent evt) {
		
	}

	public Car getCar() {
		return car;
	}

	public void setCar(Car car) {
		this.car = car;
	}


	public List<Car> getCars() {
		return cars;
	}


	public void setCars(List<Car> cars) {
		this.cars = cars;
	}
}